using System.Collections.Generic;
using Godot;

namespace Arcane.Source.TileMatch;

public interface ITile
{
    bool Matches(ITile other);
    bool Swapable(ITile other);
    bool Interactable();
    void OnMatch(Match match, TilePos pos, List<TilePos> matchedPos) { }
    void OnNeighborRemove(Match match, TilePos pos, TileSide side) { }

    public static bool IsMatch(ITile lhs, ITile rhs) => lhs?.Matches(rhs) == true;
    public static bool IsEmpty(ITile tile) => tile == null;
    public static bool IsInteractable(ITile tile) => tile?.Interactable() == true;
}

public interface IDynTile : ITile
{
    /// <summary>
    /// a dynamic Tile's tick event.
    /// </summary>
    /// <param name="match">the match that tile belongs to</param>
    /// <param name="pos">tile's position</param>
    /// <returns>returns true if should prevent match. otherwise, false.</returns>
    bool Tick(Match match, TilePos pos);
}